<?php
session_start();
if(isset($_SESSION['admin_id'])) {
    include "../include/dbFunctions.php";
    if(isset($_GET['id'])) {
        $id = $_GET['id'];
        $eQuery = "DELETE FROM quanly WHERE admin_id = '".$id."'";
        $eresult = executeQuery($eQuery);
        if ($eresult!=0) {
            $_SESSION['mes'] = "Your record has been deleted successfully";
        } else {
            $_SESSION['mes'] = "Error! Please try again";
        }
        header('Location: adminAccount.php');
    }if
    (isset($_POST['id_admin'])) {
        $id_admin=$_POST['id_admin'];
        $arr_num=count($id_admin);
        $i=0;
        while ($i < $arr_num) {
            $eQuery="DELETE FROM quanly WHERE admin_id = '".$id_admin[$i]."'";
            $eResult = executeQuery($eQuery);

            $i++;
        }
        if (($eResult!=0)) {
            $_SESSION['mes'] = "Your record has been deleted successfully";
        }else {
            $_SESSION['mes'] = "Error! Please try again";
        }
        header('Location: adminaccount.php');
    }
    
}else {
    header("Location: ../include/login.html");
}
?>